/*
*
* 对外接口operating
* */

define(["Engine","Element","cacheModel","Slice","Measure","Singer"],function(En,Element,Cache,Slice,Measure,Singer){
    
    var API = function(){
        scope = this;
        this.body = {};
        this.DB = {};
    };
    Object.assign(API.prototype,{
        
        //初始化引擎
        start: function (id) {
            Driver = new En (id);               //加载三维场景
            DBCache = new Cache({
                dataDB:{
                    version:1.0,
                    tables:[
                        {
                            name:"model",
                            keyPath:"id"
                        },
                        {
                            name:"data",
                            keyPath:"id"
                        }]
                },
                url:configData.model,
                localPlane:[],
                scene:Driver.scene,
                container:models,
                font:[
                    "./Engine/Processing/two-D_data/font/FZLT.json",                               //方正兰亭;
                    "./Engine/Processing/two-D_data/font/STSong.json",                               //新宋体;
                    "./Engine/Processing/two-D_data/font/YouYuan.json",                               //幼圆;
                    "./Engine/Processing/two-D_data/font/LiSu.json",                               //隶书;
                    "./Engine/Processing/two-D_data/font/English.json",                               //英文字体url;
                ]
            });              //初始化缓存
            Handle = new Element({
                update:Driver.update,
                dom:Driver.dom.renDom,
                camera:Driver.cameraId["camera0"],
                modelArray:models.modelArray,
                scene:Driver.sceneHelper,
                body: scope.body,
            });                    //与三维场景交互
            
        //基础性操作模块
            Handle.init();
            Handle.orbit(Driver.cameraId["camera0"],Driver.dom.renDom);
            
        //剖切模块
            Clip = new Slice(Driver,Handle);
            Clip.start();
            
        //测量模块
            Mea= new Measure(Driver,Handle);
            
        //标记模块
            Sign = new Singer(Driver,Handle);
    
            scope.DB = DBCache;
            
        },
        
        //加载模型
        load:function(url,flag){
            DBCache.config({reference: flag, url:url});
        },
        
        //重置
        reset: function () {
            //重置视角
            
            //重置剖切
            scope.clip();
            
            //重置测量
            scope.measure();
            
            
            
        },
        
        //剖切
        clip:function(boolean){
            Clip.clippingView(boolean);
        },
        
        //测量
        measure: function (boolean) {
            Mea.start(boolean);
        }
        
      
        });
        
    var models = {
        modelArray:[],
        modelGroupArray:[],
        modelContainer:{},
        modelIdIndex:[],
        modelNameIndex:[],
        modelShell:[],
        modelGroup:{},
        colorGroup:{},
    };
    var scope,Driver,Handle,DBCache,Clip,Mea,Sign;
    
    return API;
    
    
});